  @include('admin.header');
  <div class="layui-body">
    <!-- 内容主体区域 -->
   <div style="margin-top:10px;margin-left:-50px">
    <div class="layui-inline">
      <label class="layui-form-label">搜索</label>
      <div class="layui-input-inline">
        <input type="text" name="date" id="date" lay-verify="date" placeholder="选择时间" autocomplete="off" class="layui-input">
      </div>
      <span>至</span>
      <div class="layui-input-inline">
        <input type="text" name="date1" id="date1" lay-verify="date" placeholder="选择时间" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-input-inline" style="margin-left:10px">
      <button class="layui-btn" lay-submit="" lay-filter="demo1" id="search">查找</button>
      <a type="button" class="layui-btn layui-btn-primary" href="/weixinapp/public/index.php/admin/users/userslist">重置</a>
    </div>
   </div>
    
  <table id="userinfo" lay-filter="test"></table>
  <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
</script>

  <div class="layui-footer">
    © layui.com - 底部固定区域sd
  </div>
</div>
</body>
</html>
<script type="text/javascript" src="/weixinapp/public/layui/layui/layui.js"></script>
<script>
layui.use(['table','jquery'], function(){
  var table   = layui.table,
   $ = layui.jquery;
  var tablein = table.render({
  	url:'/weixinapp/public/index.php/admin/users/usersinfo',
  	elem:'#userinfo',
  	height:500,
  	cols:[[
  		{checkbox:true},
  		{field:'id',title:'ID',width:50,sort:true},
  		{field:'username',title:'用户名',width:100},
      {field:'address',title:'地址',width:200},
      {field:'phone',title:'手机号',width:150},
      {field:'odd_number',title:'快递单号',width:200},
      {field:'time',title:'获奖时间',width:200},
      {field:'code', title: '状态', width: 200},
      {fixed: 'right', width:200, align:'center', toolbar: '#barDemo'} //这里的toolbar值是模板元素的选择器
  	]],
  	page:true,
  	limits: [10],
    limit: 10 //默认采用60
  });

  $('#search').on('click', function(){
  var data = $('#date').val();
  var data1 = $('#date1').val();
  console.log(data);
  tablein.reload({
  where: { //设定异步数据接口的额外参数，任意设
    data: data
    ,data1: data1
  },
  // url:'/admin/users/search',

  })
});

  table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
  var data = obj.data; //获得当前行数据
  var layEvent = obj.event; //获得 lay-event 对应的值
  var tr = obj.tr; //获得当前行 tr 的DOM对象
  var id= data['id']; 
  if(layEvent === 'del'){ //删除
    layer.confirm('真的删除行么', function(index){
      obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
      layer.close(index);
      $.ajax({
      url:'/admin/users/dele',
      type:'post',
      data:{'id':id},
      dataType:'json',
      success:function(d){
        if(d.code==200){
          layer.msg(d.msg, {
          icon: 1,
          time: 1000 //1秒关闭（如果不配置，默认是3秒）
        });  
        }else{
          layer.msg(d.msg);
        }
       }
      })
    });
  } else if(layEvent === 'edit'){ //编辑
     location.href = "/weixinapp/public/index.php/admin/users/changeuser?id="+id;
  }
});
});




</script>
<script type="text/javascript">
  layui.use(['element','laydate'], function(){
  var element = layui.element,
  laydate     = layui.laydate;
  
  laydate.render({
    elem: '#date',
    min: '2017-1-1'
    ,theme: 'molv'
  });

  laydate.render({
    elem: '#date1'
    ,min: '2017-1-1'
    ,theme: 'molv'
  });


});


</script>












